﻿using System;
using Myotragus.Data.Containers;
using Myotragus.Data.Registration;
using Myotragus.Store.Model.Tests.Domain;
using NUnit.Framework;

namespace Myotragus.Store.Model.Tests
{
  [TestFixture]
  public class EntityContainerFixture
  {
    IEntitiesContainer Entities
    {
      get;
      set;
    }
    [SetUp]
    public void SetUp()
    {
      FixtureHelper.InitializeServices();

      var entities = FixtureHelper.Container.Resolve<IEntitiesRegistrar>();
      ((ITypeRegistrar) entities).RegisterForAll(EntitiesImplementation.FromAssemblyContaining<IObject>());

      Entities = entities;
    }

    [Test]
    public void CreateEntities()
    {
      var obj1 = Entities.Create(typeof(IObject));
      var obj2 = Entities.Create<IObject>();

      var proto = new { Name = "Name", Created=DateTime.Now, Price = 0M };
      var objp1 = Entities.Create(typeof(IObject));
      var objp2 = Entities.Create<IObject>();

      Assert.AreEqual(FixtureHelper.ToJsString(objp1), FixtureHelper.ToJsString(objp2));
    }
  }
}
